USE [influenza]
GO

/****** Object:  StoredProcedure [dbo].[SP_datResultLab]    Script Date: 02/05/2010 13:58:42 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[SP_datResultLab]
@param varchar(50)
as
Begin
declare @qry VARCHAR(8000)

SET @qry='Select c.nFolio_lab,(b.cNombre+''  ''+ b.cPaterno+'' ''+ b.cMaterno) as Paciente,
e.corto as Estado,f.tecnica,h.estudio,CONVERT(varchar(10),c.fRecepcion,103) as fRecepcion 
from dat_registro a
inner join dat_generales b on (a.id_generales= b.id_principal)
inner join dat_laboratorio c on(b.id_principal=c.id_generales)
inner join Cat_Laboratorio d on(d.id_laboratorio=c.id_laboratorio)
inner join Catalogos.dbo.entidad e on(d.nEntidad=e.entidad)
inner join cat_lab_tecnica f on (c.nTecnica=f.id_tecnica)
inner join cat_lab_estudio h on (c.nEstudio=h.id_estudio)
Where a.id_principal='+@param

exec (@qry)

End
GO

